﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Hired
{
    public partial class createjob : System.Web.UI.Page
    {
        private CompanyAccount ca;
        private EmployerPassport ep;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.IsInRole("company"))
            {
                ca = DBCompanyAccount.RetrieveCompanyAccount(User.Identity.Name, true);
                
            }
            else if (User.IsInRole("employer"))
            {
                ep = DBEmployerPassport.RetrieveEmployerPassport(User.Identity.Name);
                ca = DBCompanyAccount.RetrieveCompanyAccountByEmployerID(User.Identity.Name, true);
                ca = ep.CompanyAccount;
            }
        }

        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Job createJob = new Job();

            #region Converting field values to code attributes

            //attribute(createJob)
            createJob.Title = txtTitle.Text;
            createJob.Description = txtDescription.Text;
            //createJob.Type = txtType.Text;
            createJob.MinimumQualifications = txtQualification.Text;
            createJob.Industry = ddlJobIndustry.Text;
            createJob.Location = txtLocation.Text;
            createJob.WorkingHours = txtWorkingHours.Text;
            createJob.EstimatedSalary = txtSalary.Text;
            createJob.CAccountID = ca.CAccountID;

            #endregion
            DBJob.CreateJob(createJob);
            lblSuccessful.Visible = true;

            txtDescription.Text = "";
            txtLocation.Text = "";
            txtQualification.Text = "";
            txtSalary.Text = "";
            txtWorkingHours.Text = "";
            txtTitle.Text = "";
            ddlJobIndustry.ClearSelection();
            ddlType.ClearSelection();


           

        }

       
    }
}